{% extends "base.html" %}

{% block content %}
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">
                    <h4 class="card-title mb-0">编辑质量追溯记录</h4>
                </div>
                <div class="card-body">
                    <form method="POST">
                        <div class="mb-3">
                            <label class="form-label">批次号</label>
                            <input type="text" class="form-control" value="{{ trace.batch_number }}" readonly>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">产品名称</label>
                            <input type="text" class="form-control" name="product_name" value="{{ trace.product_name }}" required>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">生产日期</label>
                            <input type="date" class="form-control" name="production_date" value="{{ trace.production_date.strftime('%Y-%m-%d') }}" required>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">有效期</label>
                            <input type="date" class="form-control" name="expiration_date" value="{{ trace.expiration_date.strftime('%Y-%m-%d') }}" required>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">生产商</label>
                            <input type="text" class="form-control" name="manufacturer" value="{{ trace.manufacturer }}" required>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">储存条件</label>
                            <input type="text" class="form-control" name="storage_condition" value="{{ trace.storage_condition }}">
                        </div>
                        <div class="mb-3">
                            <label class="form-label">质量标准</label>
                            <input type="text" class="form-control" name="quality_standard" value="{{ trace.quality_standard }}">
                        </div>
                        <div class="mb-3">
                            <label class="form-label">检验员</label>
                            <input type="text" class="form-control" name="inspector" value="{{ trace.inspector }}">
                        </div>
                        <div class="mb-3">
                            <label class="form-label">检验日期</label>
                            <input type="date" class="form-control" name="inspection_date" value="{{ trace.inspection_date.strftime('%Y-%m-%d') if trace.inspection_date else '' }}">
                        </div>
                        <div class="mb-3">
                            <label class="form-label">检验结果</label>
                            <select class="form-select" name="inspection_result">
                                <option value="pending" {% if trace.inspection_result == 'pending' %}selected{% endif %}>待检验</option>
                                <option value="passed" {% if trace.inspection_result == 'passed' %}selected{% endif %}>合格</option>
                                <option value="failed" {% if trace.inspection_result == 'failed' %}selected{% endif %}>不合格</option>
                            </select>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">备注</label>
                            <textarea class="form-control" name="notes" rows="3">{{ trace.notes }}</textarea>
                        </div>
                        <div class="d-grid gap-2">
                            <button type="submit" class="btn btn-primary">保存修改</button>
                            <a href="{{ url_for('quality.trace_list') }}" class="btn btn-secondary">返回列表</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %} 